<!-- // 处理多语言 -->
<script lang="ts" setup>
import { ReloadOutlined } from '@vicons/antd'
import type { TabItem } from './type.ts'
import { useMultiTab } from '~/composables/multi-tab-state.ts'

const props = defineProps<{
  item: TabItem
  onContextMenu: (e: MouseEvent) => void
}>()

const { refresh, current } = useMultiTab()

const { t: $t } = useI18n() as any

function handleRefresh() {
  refresh()
}

function handleContextMenu(e: MouseEvent) {
  props.onContextMenu(e)
}
</script>

<template>
  <span @contextmenu="handleContextMenu">
    {{ $t(item.tabTitle) }}
  </span>
  <n-icon
    v-if="current === item.path"
    class="ml-2 n-base-close n-tabs-tab_close"
    @click="handleRefresh"
  >
    <ReloadOutlined />
  </n-icon>
</template>

<style scoped></style>
